import React from 'react';

import ExpandableCard, { type ExpandableCardProps } from './index';

import type { DescriptionsProps } from 'antd';

export interface ExpandableDescriptionsProps extends Omit<ExpandableCardProps, 'children'> {
  /** Descriptions 组件的属性 */
  descriptionsProps?: DescriptionsProps;
  /** 基础字段（始终显示） */
  basicItems: React.ReactNode[];
  /** 扩展字段（展开时显示） */
  expandedItems: React.ReactNode[];
}

const ExpandableDescriptions: React.FC<ExpandableDescriptionsProps> = ({
  descriptionsProps,
  basicItems,
  expandedItems,
  ...cardProps
}) => {
  return (
    <ExpandableCard {...cardProps}>
      {expanded => (
        <ADescriptions column={2} size="small" bordered {...descriptionsProps}>
          {/* 基础字段 - 始终显示 */}
          {basicItems}

          {/* 扩展字段 - 展开时显示 */}
          {expanded && expandedItems}
        </ADescriptions>
      )}
    </ExpandableCard>
  );
};

export default ExpandableDescriptions;
